package accounts;


import itsbank.*;
import java.util.*;

/**
 * generic account class from which all other types of accounts can be derived
 * @author Mike
 */

public abstract class Account {
    private LinkedList<Transaction> transactions;
    private int ownerID;
    private int bankID;
    private int accountID;

    /**
     * abstract methode to return the balance of the account, has to be implemented
     * in every type of account
     * @return the balance
     */
    public abstract int getBalance ();
    /**
     * adds a new transaction to the queue
     * @param transaction the transaction to be added
     */
    public final void addTransaction(Transaction transaction) {
        transactions.add(transaction);
        if (transactions.size() > 100) {
            transactions.remove();
        }
    }
    /**
     * gets the amount of transactions stored in the account
     * @return the number of transactions
     */
    public final int getNumberOfTransactions(){
        return transactions.size();
    }
    /**
     * gets a specific transaction number
     * @param num the number of the transaction
     * @return the transaction
     */
    public final Transaction getTransaction(int num) {
        return transactions.get(num);
    }
    /**
     * returns the account number
     * @return the account number
     */
    public final int getAccountNo() {
        return accountID;
    }
    /**
     * constructor set basic infos of account
     * @param _bank the identifier of the bank
     * @paran accountNr the account number
     * @param _owner the owner of the account
     */
    public Account(int _bank, int accountNr, int _owner) {
        bankID = _bank;
        accountID = accountNr;
        ownerID = _owner;
        transactions = new LinkedList<Transaction>();
    }
}

